#ifndef _VIDEO_MANAGER_H
#define _VIDEO_MANAGER_H

#include <pic_operation.h>

#define NB_BUFFER 4 // 队列中最多存放四个帧缓冲区

struct VideoDevice;
struct VideoOpr;

typedef T_VideoDevice T_VideoDevice;
typedef T_VideoOpr T_VideoOpr;

// 视频设备结构体
typedef struct VideoDevice{
    int iFd;
    int iPixelFormat;
    int iWidth;
    int iHeight;

    int iVideoBufCnt; // 视频缓冲区数量
    int iVideoBufMaxLen; // 视频缓冲区最大长度
    int iVideoBufCurIndex; // 当前视频缓冲区索引
    unsigned char *pucVideBuff[NB_BUFFER]; // 视频缓冲区指针数组
    // 视频操作函数
    PT_VideoOpr ptOpr;
    
}T_VideoDevice, *PT_VideoDevice;



typedef struct VideoBuff{
    T_PixelDatas tPixelDatas; // 像素数据结构体
    int iPixelFormat; // 像素格式
}T_VideoBuff, *PT_VideoBuff;



typedef struct VideoOpr{
    char *name;
    int (*InitDevice)(char *strDevName, PT_VideoDevice ptVideoDevice);
    int (*ExitDevice)(PT_VideoDevice ptVideoDevice);
    int (*GetFormats)(PT_VideoDevice ptVideoDevice);
    int (*GetFrame)(PT_VideoDevice ptVideoDevice, PT_VideoBuff ptVideoBuff);
    int (*PutFrame)(PT_VideoDevice ptVideoDevice, PT_VideoBuff ptVideoBuff);
    int (*StartDevice)(PT_VideoDevice ptVideoDevice);
    int (*StopDevice)(PT_VideoDevice ptVideoDevice);
    struct VideoOpr *ptNext;
}T_VideoOpr, *PT_VideoOpr;


void RegisterVideoOpr(PT_VideoOpr ptVideoOpr);
int InitVideoDevice(char *name, PT_VideoDevice ptVideoDevice);

#endif